import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'logic.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);

  final logic = Get.put(HomeLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("LED时钟"),
        centerTitle: true,
        bottom: _buildTabbar(),
      ),
      body: _buildTabbarView(),
    );
  }

  // Tabbar
  PreferredSizeWidget _buildTabbar() => TabBar(
        controller: logic.tabController,
        tabs: logic.tabs.keys
            .map(
              (e) => Tab(
                icon: Icon(logic.tabs[e]),
                text: e,
              ),
            )
            .toList(),
      );
  // Tabbar 滑动视图
  Widget _buildTabbarView() => TabBarView(
        controller: logic.tabController,
        children: logic.tabview,
      );
}
